<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form"%>
<!doctype html>

<html dir="ltr" lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>欢迎登陆cbd平台</title>
<meta name="keywords" content="webos" />
<meta name="description" content="webos" />
<meta name="Language" content="zh-CN" />
<meta name="Copyright" content="webos" />
<meta name="Designer" content="webos" />
<meta name="Publisher" content="webos" />
<meta name="Distribution" content="Global" />
<meta name="author"  content="webos" />
<meta name="robots" content="index,follow" />
<meta name="googlebot" content="index,follow,archive" />
<link href="css/main1.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        p{
            text-align: center;
        }
        a{ color:#2c850d; text-decoration:none;}
		a:link{ color:#2c850d; text-decoration:none;}
		a:visited{ color:#2c850d; text-decoration:none;}
		a:hover{ color:#ff2020; text-decoration:underline;}
		a:actived{ color:#2c850d; text-decoration:none;}
    </style>
</head>
<body>


<div class="login">
    <div class="box png">
		<div class="logo"></div>
		<div class="input">
			<div class="log">
			<input type="hidden" id="loginType" value="${sessionScope.login }">
			<form id="loginForm" action="login.do" class="form-horizontal" method="post"
			 commandName="user">
				<div style="padding:0px;" class="name">
					<label>用户名</label><input type="text" class="text" onblur="checkUserName()" onfocus="cleanUserName()" placeholder="用户名" name="userName"  id="userName" tabindex="1">
					<label id="trueuser" style="position:absolute;top:82px;left:290px;color:green;"></label>
                    <p style="height:25px; padding-left:30px;" id="checkName"></p>
				</div>
				<div style="padding:0px;" class="pwd">
					<label>密　码</label><input id="password" name="userPWD" type="password" class="text" onfocus="cleanPassword()" onblur="checkPassword()" placeholder="密码" name="value_2" tabindex="2">
					<label id="truepwd" style="position:absolute;top:132px;left:290px;color:green;"></label>
                     <p style="height:20px; padding-left:30px;" id="checkPassword"></p>
					<input type="submit" class="submit" onclick="return check()" tabindex="3" value="登录">
                   <p><a style="float:right;" href="regist.jsp">没有账号？马上注册</a></p>
					<div class="check"></div>
				</div>
				<div class="tip"></div>
				</form>
			</div>
		</div>
	</div>
    <div class="air-balloon ab-1 png"></div>
	<div class="air-balloon ab-2 png"></div>
    <div class="air-balloon ab-1 png"></div>
    <div class="footer"></div>
</div>

<script type="text/javascript" src="jslib/jQuery.js"></script>
<script type="text/javascript" src="js/fun.base.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript">
		function check(){
			var flag = checkUserName() && checkPassword();
			return flag;
		}
		function checkUserName(){
			var userName = document.getElementById("userName").value;
			var userNameMessage = document.getElementById("checkName");
			var eReg =  /^[a-zA-Z][a-zA-Z0-9]{5,19}$/;
			if (userName.length == 0) {
				userNameMessage.innerHTML = "×用户名不能为空";
				$("#trueuser").html("");
				userNameMessage.style.color="red";
				return false;
			} else if (!eReg.test(userName)) {
				userNameMessage.innerHTML = "×用户名以字母开头，长度6-20位";
				userNameMessage.style.color="red";
				$("#trueuser").html("");
				return false;
			} else {
				$("#trueuser").html("√");
				return true;
			}	
		}
		function checkPassword(){
			var password = document.getElementById("password").value;
			var passwordMessage = document.getElementById("checkPassword");
			var eReg =  /^[a-zA-Z][a-zA-Z0-9]{5,19}$/;
			if (password.length == 0) {
				passwordMessage.innerHTML = "×密码不能为空";
				$("#truepwd").html("");
				passwordMessage.style.color="red";
				return false;
			} else if (!eReg.test(password)) {
				passwordMessage.innerHTML = "×密码必须字母开头，长度6-20位";
				$("#truepwd").html("");
				passwordMessage.style.color="red";
				return false;
			} else {
				$("#truepwd").html("√");
				return true;
			}		
		}
		function cleanUserName(){
			var userNameMessage = document.getElementById("checkName");
			$("#trueuser").html("");
			userNameMessage.innerHTML = "";
		}
		function cleanPassword(){
			var passwordMessage = document.getElementById("checkPassword");
			$("#truepwd").html("");
			passwordMessage.innerHTML="";
		}
		$(function(){
			var loginType = eval("<%=request.getSession().getAttribute("login")%>")
			if(loginType=="0"){
				$("#checkPassword").html("用户名或密码错误，请重新输入");
				$("#checkPassword").css("color","red");
			}else if(loginType=="1"){
				window.location.href="cbd/landlady/landladyMain.jsp";
			}else if(loginType=="2"){
				window.location.href="cbd/renter/renterMain.jsp";
			}else if(loginType=="3"){
				window.location.href="cbd/company/companyMain.jsp";
			}else if(loginType=="4"){
				window.location.href="cbd/Operator/operatorMain.jsp";
			}
		})
	</script>

</body>
</html> 